package com.uniledger.exchange.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;
import com.uniledger.commonlib.util.NumberUtils;
import com.uniledger.exchange.contact.UniContact;

public class StellarAsset implements Parcelable {

    public long id;
    public String state;

    public String currency;//资产类型
    public String amount;//资产数量

    @SerializedName("access_token")
    public String token;

    @SerializedName("expired_at")
    public String expired;
    public String issue_addr;
    public String base_addr;
    public String logo;

    public StellarAsset() {
        this.currency = "AED";
        this.amount = "0";
    }

    public String getAmount() {
        return NumberUtils.formatRate(amount);
    }

    /**
     * 收款码
     */
    public String pay_url;
    public String accountId;//钱包地址

    @SerializedName("payee")
    public UniContact contact;


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(this.id);
        dest.writeString(this.state);
        dest.writeString(this.currency);
        dest.writeString(this.amount);
        dest.writeString(this.token);
        dest.writeString(this.expired);
        dest.writeString(this.issue_addr);
        dest.writeString(this.base_addr);
        dest.writeString(this.logo);
        dest.writeString(this.pay_url);
        dest.writeString(this.accountId);
        dest.writeParcelable(this.contact, flags);
    }

    protected StellarAsset(Parcel in) {
        this.id = in.readLong();
        this.state = in.readString();
        this.currency = in.readString();
        this.amount = in.readString();
        this.token = in.readString();
        this.expired = in.readString();
        this.issue_addr = in.readString();
        this.base_addr = in.readString();
        this.logo = in.readString();
        this.pay_url = in.readString();
        this.accountId = in.readString();
        this.contact = in.readParcelable(UniContact.class.getClassLoader());
    }

    public static final Creator<StellarAsset> CREATOR = new Creator<StellarAsset>() {
        @Override
        public StellarAsset createFromParcel(Parcel source) {
            return new StellarAsset(source);
        }

        @Override
        public StellarAsset[] newArray(int size) {
            return new StellarAsset[size];
        }
    };
}
